package com.deanlib.cabinet.data.model;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * Created by Dean on 2022/6/21
 */
public class User implements Parcelable {

    public Long id;//主键唯一
    public String username;//唯一
    public String nickname;
    public String phoneNumber;//唯一
    public String email;//唯一
    public Integer gender;
    public String country;
    public String city;
    public String address;
    public Long birthday;


    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeValue(this.id);
        dest.writeString(this.username);
        dest.writeString(this.nickname);
        dest.writeString(this.phoneNumber);
        dest.writeString(this.email);
        dest.writeValue(this.gender);
        dest.writeString(this.country);
        dest.writeString(this.city);
        dest.writeString(this.address);
        dest.writeValue(this.birthday);
    }

    public void readFromParcel(Parcel source) {
        this.id = (Long) source.readValue(Long.class.getClassLoader());
        this.username = source.readString();
        this.nickname = source.readString();
        this.phoneNumber = source.readString();
        this.email = source.readString();
        this.gender = (Integer) source.readValue(Integer.class.getClassLoader());
        this.country = source.readString();
        this.city = source.readString();
        this.address = source.readString();
        this.birthday = (Long) source.readValue(Long.class.getClassLoader());
    }

    protected User(Parcel in) {
        this.id = (Long) in.readValue(Long.class.getClassLoader());
        this.username = in.readString();
        this.nickname = in.readString();
        this.phoneNumber = in.readString();
        this.email = in.readString();
        this.gender = (Integer) in.readValue(Integer.class.getClassLoader());
        this.country = in.readString();
        this.city = in.readString();
        this.address = in.readString();
        this.birthday = (Long) in.readValue(Long.class.getClassLoader());
    }

    public static final Parcelable.Creator<User> CREATOR = new Parcelable.Creator<User>() {
        @Override
        public User createFromParcel(Parcel source) {
            return new User(source);
        }

        @Override
        public User[] newArray(int size) {
            return new User[size];
        }
    };
}
